from redis import StrictRedis
import logging


class Config(object):
    # mysql数据库链接
    SQLALCHEMY_DATABASE_URI = "mysql://root:mysql@127.0.0.1:3306/information2"
    # 数据跟踪操作
    SQLALCHEMY_TRACK_MODIFICATIONS = True
    # redis数据库ip
    REDIS_HOST = "127.0.0.1"
    # redis数据库端口号
    REDIS_PORT = 6379
    # 按照utf8的格式将数据装换为字符串类型
    DECODE_RESPONSES = True
    # 储存类型
    SESSION_TYPE = "redis"
    # 储存的数据库
    SESSION_REDIS = StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    # 加密处理
    SESSION_USE_SIGNER = True
    # 设置session 的有效期，单位是秒
    PERMANENT_SESSION_LIFETIME = 86400
    # 设置加密字符串
    SECRET_KEY = "sfAADSGSGsdgdsgGSDgadgarddafdf"


class DevelopmentConfig(Config):
    """开发模式配置类"""
    # 日志等级为debug
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    """生产模式配置类"""
    # 日志等级为error
    LOG_LEVEL = logging.ERROR


config_dict = {
    "development": DevelopmentConfig,
    "production": ProductionConfig
}
